package Ara_Con;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import Ara_Dao.RboardDao;

public class QboardDetail implements Controller{

	private RboardDao rboardDao;
	
	public void setRboardDao(RboardDao rboardDao) {
		this.rboardDao = rboardDao;
	}
	
	@Override
	public ModelAndView handleRequest(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {
		
		String rb_no = arg0.getParameter("rb_no");
		
		String back = Integer.toString(Integer.parseInt(arg0.getParameter("rb_no")) - 1) ;
		String next = Integer.toString(Integer.parseInt(arg0.getParameter("rb_no")) + 1) ;
		
		System.out.println(back);
		System.out.println(next);
		
		Object backList = rboardDao.QboardDetail(back);
		Object nextList = rboardDao.QboardDetail(next);
		Object rboard = rboardDao.QboardDetail(rb_no);
		List<?> ripple = rboardDao.QboardcmDetail(arg0.getParameter("ripple_subid"));
		
		ModelAndView mav = new ModelAndView();
		mav.addObject("rboard",rboard);
		mav.addObject("backList",backList);
		mav.addObject("nextList",nextList);
		mav.addObject("rippledetail",ripple);
		mav.setViewName("QboardDetail");
		
		return mav;
	}
	
}
